package _interview150;

/**
 * 27. 移除元素
 */
public class No27 {
    public int removeElement(int[] nums, int val) {
        int right = nums.length;
        for (int left = 0; left < right; left++) {
            if (nums[left] == val) {
                while (--right > left && nums[right] == val) ;
                nums[left] = nums[right];
            }
        }
        return right;
    }
}
